<html>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href='./css/style.css'>
    <title>dttan-web2</title>
    <body class="body">
    <div class="menu">
        <ul>
            <li><a href="#"> TRANG CHỦ</a></li>
           <li><a href="#">GIỚI THIỆU</a></li>
            <li><a href="#"><strong>SẢN PHẨM</strong></a>
               <ul>
                 <li><a href="#">APPLE</a></li>
                 <li><a href="#">DELL</a></li>
                 <li><a href="#">SAMSUNG</a></li>
                 <li><a href="#">PANASONIC</a></li>
               </ul>
           </li>   
           
          <li><a href="#"><strong>THIẾT BỊ MẠNG</strong></a>
               <ul>
                 <li><a href="#">USB 3G</a></li>
                 <li><a href="#">HUB-SWICHT</a></li>
                 <li><a href="#">CABLE MẠNG</a></li>
                 <li><a href="#">KHÁC</a></li>
               </ul>
           </li>
            <li><a href="#"> THIẾT BỊ VĂN PHÒNG</a>
                <ul>
                 <li><a href="#">MÁY IN</a></li>
                 <li><a href="#">MÁY SCAN</a></li>
                 <li><a href="#">MÁY FAX</a></li>
                 <li><a href="#">MÁY TÍNH TIỀN</a></li>
               </ul>
            </li>
            <li><a href="#">LIÊN HỆ</a></li>
        </ul>
           <div class="thanh"></div>
        </div>
    <div class="thanh"></div>
    <div class="hinh">
         
            <form method="post">
                <input type="input" name="input" id="input">
                <input type="submit" name="submit" value="Seach">
</form>
    </div>
    <div class="thanh"></div>
    <h3 align="center">
            <?php
            require_once './model/db.php';
            require_once './model/keywords.php';
            require_once './model/works.php';
            $works = new works();
          $a = 0;
            ?> 
        <div class="navNext">
        <nav>     
            <ul> 
            <?php $page = $works->count() / PER_PAGE; ?>
 
                <li> <a href='index.php?page=1'> FIRST </a></li>
             <li><a href='index.php?page=<?php echo $_GET["page"] - 1 ?>'> Prev </a></li>

            <?php for ($i = 1; $i <= 7; $i++): ?>
                <?php if (($_GET["page"] == 1) || ($_GET["page"] == 2) || ($_GET["page"] == 3) || ($_GET["page"] == 4)): ?>            
                    <?php for ($i = 1; $i <= 7; $i++): ?>
                        <li><a href='index.php?page=<?php echo $i; ?> '><?php echo $i ?></a></li>
                        <?php if ($_GET["page"] == $i): ?>
                            <?php $works->bd = (($i - 1) * 10); ?>
                            <?php $works->end = PER_PAGE; ?>
                        <?php endif; ?>
                    <?php endfor; ?>

                <?php elseif (($_GET["page"] == $page) || ($_GET["page"] == $page - 1) || ($_GET["page"] == $page - 2) || ($_GET["page"] == $page - 3)): ?>        
                    <?php for ($i = $page - 7; $i <= $page; $i++): ?>
                        <li><a href='index.php?page=<?php echo $i; ?> '><?php echo $i ?></a></li>
                        <?php if ($_GET["page"] == $i): ?>
                            <?php $works->bd = (($i - 1) * 10); ?>
                            <?php $works->end = PER_PAGE; ?>
                        <?php endif; ?>
                    <?php endfor; ?>

                <?php else : ?>
                    <?php for ($i = $_GET["page"] - 3; $i <= $_GET["page"] + 3; $i++): ?>
                        <li><a href='index.php?page=<?php echo $i; ?> '><?php echo $i ?></a></li>
                        <?php if ($_GET["page"] == $i): ?>
                            <?php $works->bd = (($i - 1) * 10); ?>
                            <?php $works->end = PER_PAGE; ?>
                        <?php endif; ?>
                    <?php endfor; ?>
                <?php endif; ?> 
            <?php endfor; ?>   

   <li><a href='index.php?page=<?php echo $_GET["page"] + 1 ?>'> Next </a></li>
             


   <li><a href='index.php?page=<?php echo $page; ?>'> LAST </a></li>
            </ul>
      </nav>
    </div>
            </br>
            </br>
    </h3>
    <?php $list_of_works = $works->select(); ?>
    <table border="2px">
        <tr  id="tr">
            <td>ID </td>
            <td>Name </td> 
            <td>Image </td>
            <td>location</td>
            <td>company_address</td>
            <td>description </td>
        </tr>
        <?php foreach ($list_of_works as $list1): ?>
            <tr>
                <td><?php echo $list1["id"]; ?></td>
                <td><?php echo $list1["name"]; ?></td>
                <td><?php echo $list1["image"]; ?> </td>
                <td><?php echo $list1["location"]; ?></td>
                <td><?php echo $list1["company_address"]; ?></td>
                <td><?php echo $list1["description"]; ?></td>
                <td><img src="css/edit1.png" width="20px" height="20px"/><a href="index_edit.php?id=<?php echo $list1["id"]; ?>"> edit </a><br>
                    <img src="css/view.png" width="20px" height="20px"/>   <a href="index_edit.php?page="> View </a><br>
                    <img src="css/Delete1.png" width="20px" height="20px"/>   <a href="index_edit.php?page="> Del... </a>
                </td>
                
            </tr>
        <?php endforeach; ?>
    </table>
    <br>
    <div class="footer">Trường Cao Đẳng Công Nghệ Thủ Đức.<br>Design by Tân Đoàn Thanh.</br></div>
</body>
</html>
